package org.mapdroid.data.adt;

import java.util.List;

import org.mapdroid.R;

import android.os.Parcelable;

import com.google.android.maps.GeoPoint;

public abstract class MdService implements Parcelable{
	/*
	 * FORMAT
	 * <INT:CATEGORY>,<STRING:NAME>,<STRING:ADDRESS>,<STRING:PHONE>,<STRING:PHOTO>,[<STRING:GALLERY>-...],<STRING:LINK>,<INT:LAT>,<INT:LON>
	 */
	
	protected String name;
	protected String address;
	protected String phoneNumber;
	protected String description;
	protected int photo;  			//url
	protected List<Integer> gallery;
	protected String link;
	protected int category;
	//protected String[] openingTime, closingTime, openingDay;
	protected GeoPoint position;

	//Category of Services
	public static final int PARKING			= 0;
	public static final int RESTAURANT 		= 1;
	public static final int CLOTHING		= 2;
	public static final int GYM				= 3;
	public static final int BEAUTY_CENTER	= 4;
	
	public static final int[] CATEGORIES_RESOURCES = {
		R.string.parking,
		R.string.restaurant,
		R.string.clothing,
		R.string.gym,
		R.string.beauty_center
	};
	
	public MdService(	String name, 
						String address, 
						String phoneNumber, 
						String description, 
						int photo, 
						String link,
						int category,
						GeoPoint position){
		this.name = name;
		this.address = address;
		this.phoneNumber = phoneNumber;
		this.description = description;
		this.photo = photo;
		this.link = link;
		this.category = category;
		this.position = position;
	}
	
	public void setName(String name){
		this.name=name;
	}
	public void setAddress(String address){
		this.address=address;
	}
	public void setPhoneNumber(String phoneNumber){
		this.phoneNumber=phoneNumber;
	}
	public void setDescription(String description){
		this.description=description;
	}
	public void setPhoto(int photo){
		this.photo=photo;
	}
	public void setLink(String link){
		this.link=link;
	}
	public void setPosition(GeoPoint position){
		this.position=position;
	}
	
	public String getName(){
		if(name==null)
			return null;
		if(name.length()<=1)
			return null;
		
		return name;
	}
	public String getAddress(){
		if(address==null)
			return null;
		if(address.length()<=1)
			return null;
		
		return address;
	}
	
	public String getPhoneNumber(){
		if(phoneNumber==null)
			return null;
		if(phoneNumber.length()<=1)
			return null;
		
		return phoneNumber;
	}
	
	public String getDescription(){
		if(description==null)
			return null;
		if(description.length()<=1)
			return null;
		
		return description;
	}
	
	public int getPhoto(){
		return photo;
	}
	
	public List<Integer> getGallery(){
		return gallery;
	}
	
	public String getLink(){
		if(link==null)
			return null;
		if(link.length()<=1)
			return null;
		
		return link;
	}
	
	public int getCategory(){
		return category;
	}
	
	public GeoPoint getPosition(){
		return position;
	}
	
	public boolean equals(MdService s){
		super.equals(s);
		if(	this.category == s.category 		&&
			this.name.contentEquals(s.name)		&&
			this.position.getLatitudeE6() == s.position.getLatitudeE6()	&&
			this.position.getLongitudeE6()== s.position.getLongitudeE6() )
			return true;
		
		return false;
	}
}
